package com.project_test.kun.travelling_1st.MinePage;


import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.project_test.kun.travelling_1st.R;


/**
 * A simple {@link Fragment} subclass.
 */
public class PersonalFragment extends Fragment {
    private LinearLayout order_layout, personal_layout, common_layout, boss_layout, tucao_layout, eliminate_layout, about_layout;
    private View.OnClickListener mClickListener;
    private View.OnClickListener mClickListener1;
    private View.OnClickListener mClickListener2;


    public PersonalFragment() {
        // Required empty public constructor
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_personal, container, false);
        order_layout = (LinearLayout) view.findViewById(R.id.order_layout);
        personal_layout = (LinearLayout) view.findViewById(R.id.personal_layout);
        common_layout = (LinearLayout) view.findViewById(R.id.common_layout);
        boss_layout = (LinearLayout) view.findViewById(R.id.boss_layout);
        tucao_layout = (LinearLayout) view.findViewById(R.id.tucao_layout);
        eliminate_layout = (LinearLayout) view.findViewById(R.id.eliminate_layout);
        about_layout = (LinearLayout) view.findViewById(R.id.about_layout);
        initLayoutClick();


        ImageView user = (ImageView) view.findViewById(R.id.head);
        user.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
//                Intent intent=new Intent(getActivity(),LogInActivity.class);
                Intent intent = new Intent(getActivity(), LogInActivity.class);
                startActivity(intent);
            }
        });


        return view;
    }

    private void initLayoutClick() {
        order_layout.setClickable(true);
        mClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), LogInActivity.class);
                startActivity(intent);
            }
        };
        order_layout.setOnClickListener(mClickListener);
        boss_layout.setClickable(true);
        boss_layout.setOnClickListener(mClickListener);
        tucao_layout.setClickable(true);
        tucao_layout.setOnClickListener(mClickListener);
        eliminate_layout.setClickable(true);
        about_layout.setClickable(true);
        about_layout.setOnClickListener(mClickListener);


        personal_layout.setClickable(true);
        mClickListener1 = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), InfoActivity.class);
                startActivity(intent);
            }
        };
        personal_layout.setOnClickListener(mClickListener1);
        common_layout.setClickable(true);
        mClickListener2 = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), NoticeActivity.class);
                startActivity(intent);
            }
        };
        common_layout.setOnClickListener(mClickListener2);


    }

}
